using System.Collections.Generic;
using abilities.effects;
using LitJson;

namespace abilities.templates
{
    public class EffectParameterModifierTemplate : EffectTemplate
    {
        public string parameter { get; private set; }
        public List<int> delta { get; private set; }= new ();
        public bool settingDirectly { get; private set; }
        public bool onlyCurrent { get; private set; }
        public string increment { get; private set; }
        public bool restoreOnCancel { get; private set; }

        public EffectParameterModifierTemplate() : base()
        {
            this.parameter = "";
            this.settingDirectly = false;
            this.onlyCurrent = false;
            this.increment = "";
            this.restoreOnCancel = false;
        }

        public override Effect CreateInstance(int level)
        {
            return new EffectParameterModifier(this,level);
        }

        public override bool FromJson(JsonData value)
        {
            if (!base.FromJson(value))
                return false;
            parameter = (string)value["parameter"];
            FromJsonToArray(value["delta"], delta);
            settingDirectly = (bool)value["settingDirectly"];
            onlyCurrent = (bool)value["onlyCurrent"];
            increment = (string)value["increment"];
            restoreOnCancel = (bool)value["restoreOnCancel"];
            return true;
        }

        public int GetDelta(int level)
        {
            return GetByLevel(delta, level);
        }
    }
}